package com.wcs.exam.common.config;

/**
 * @author wcs
 */
public final class ThreadContext {


    private final static ThreadLocal<Long> USER_ID_LOCAL = new ThreadLocal<>();

    private ThreadContext() {
    }

    public static Long getUserId() {
        return USER_ID_LOCAL.get();
    }

    public static void removeUserId() {
        USER_ID_LOCAL.remove();
    }

    public static void setUserId(Long val) {
        if (val == null) {
            removeUserId();
            return;
        }
        USER_ID_LOCAL.set(val);
    }
}
